﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.SharePoint.Commands;
using SPVSX.Explorer.Extensions;
using Microsoft.SharePoint;
using SPVSX.Explorer.Commands.SharePoint;
using SPVSX.Explorer.Extensions.NodeInformation;
using SPVSX.Explorer.Extensions.CommandIds;

namespace SPVSX.Explorer.Commands
{
    class HideCustomActionCommands
    {
        // Gets data for each Hide Custom Action on the SharePoint site, and returns an array of 
        // serializable objects that contain the data.
        [SharePointCommand(HideCustomActionCommandIds.GetHideCustomActions)]
        private static HideCustomActionNodeInfo[] GetHideCustomActions(ISharePointCommandContext context)
        {
            var nodeInfos = new List<HideCustomActionNodeInfo>();

            //Here is where this will call out to the smarts from SAS but for now create some dummy data

            ElementProvider availableProvider = ElementProvider.GetAvailableProvider();

            //List<HideCustomActionElement> group =
            //    availableProvider.QueryForCustomActionGroupsByLocationAndGroupId(context.Web,
            //                                                                     FeatureScope,
            //                                                                     Location,
            //                                                                     GroupId);

            for (int i = 0; i < 10; i++)
            {
                HideCustomActionNodeInfo info = new HideCustomActionNodeInfo();
                info.Name = "Name " + i.ToString();

                nodeInfos.Add(info);
            }

            return nodeInfos.ToArray();
        }

        // Gets additional property data for a specific Hide Custom Action.
        [SharePointCommand(HideCustomActionCommandIds.GetHideCustomActionProperties)]
        private static Dictionary<string, string> GetHideCustomActionProperties(ISharePointCommandContext context,
            HideCustomActionNodeInfo nodeInfo)
        {
            //As the get of the info object is already expensive here we simply read back the properties from it
            //rather than harvest it again

            return SharePointCommandServices.GetProperties(nodeInfo);
        }
    }
}